package com.hzqy.service.statistics;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.hzqy.persistence.dao.statistics.OrderTimePeriodsDao;
import com.hzqy.service.core.GenericServiceBean;
import com.hzqy.web.vo.PmsUserVo;
import com.hzqy.web.vo.StatDataOrderSourceVo;
import com.hzqy.web.vo.StatDataOrderTimePeriodsVo;

@Service
public class OrderTimePeriodsServiceBean extends GenericServiceBean<PmsUserVo, OrderTimePeriodsDao, Integer>{
	private static final long serialVersionUID = 1L;
	protected final Logger LOG = LoggerFactory.getLogger(getClass());
	
	@Resource
	private OrderTimePeriodsDao orderTimePeriodsDao;
	
	@Override
	public OrderTimePeriodsDao getEntityDao() {
		return orderTimePeriodsDao;
	}
	

	public Map<String, Object> selectOrderTimePeriodsList(StatDataOrderTimePeriodsVo statDataOrderTimePeriodsVo, int curPage, int pageSize) {
		Map<String,Object> map = new HashMap<String, Object>();
		Integer rowCount = orderTimePeriodsDao.selectOrderTimePeriodsCount(statDataOrderTimePeriodsVo);
		map.put("total", rowCount);
		if(rowCount > 0 && curPage > 0 && pageSize > 0) {
			map.put("firstResult", (curPage-1)*pageSize);
			map.put("maxResults", pageSize);
			map.put("f_sdotp_type", statDataOrderTimePeriodsVo.getF_sdotp_type());
			map.put("f_sdotp_productid", statDataOrderTimePeriodsVo.getF_sdotp_productid());
			map.put("beginDate", statDataOrderTimePeriodsVo.getBeginDate());
			map.put("endDate", statDataOrderTimePeriodsVo.getEndDate());
			map.put("monthDate", statDataOrderTimePeriodsVo.getMonthDate());
			map.put("weekDate", statDataOrderTimePeriodsVo.getWeekDate());
			List<StatDataOrderTimePeriodsVo> results = orderTimePeriodsDao.selectOrderTimePeriodsList(map);
			map.put("rows", results);
		} else {
			map.put("rows", new ArrayList<StatDataOrderTimePeriodsVo>());
		}
		return map;
	}
	
	public Map<String,Object> selectExcelList(StatDataOrderTimePeriodsVo statDataOrderTimePeriodsVo) {
		Map<String,Object> map = new HashMap<String, Object>();
		Integer rowCount = orderTimePeriodsDao.selectOrderTimePeriodsCount(statDataOrderTimePeriodsVo);
		map.put("total", rowCount);
		if(rowCount > 0) {
			map.put("f_sdotp_type", statDataOrderTimePeriodsVo.getF_sdotp_type());
			map.put("f_sdotp_productid", statDataOrderTimePeriodsVo.getF_sdotp_productid());
			map.put("beginDate", statDataOrderTimePeriodsVo.getBeginDate());
			map.put("endDate", statDataOrderTimePeriodsVo.getEndDate());
			map.put("monthDate", statDataOrderTimePeriodsVo.getMonthDate());
			map.put("weekDate", statDataOrderTimePeriodsVo.getWeekDate());
			List<StatDataOrderTimePeriodsVo> results = orderTimePeriodsDao.selectOrderTimePeriodsExcelList(map);
			map.put("rows", results);
		} else {
			map.put("rows", new ArrayList<StatDataOrderTimePeriodsVo>());
		}
		return map;
	}
	
}
